Iterator

interface Iterator<out T>

An iterator over a collection or another entity that can be represented as a sequence of elements. Allows to sequentially access the elements.

Functions

hasNext
Link copied to clipboard
abstract operator fun hasNext(): Boolean

Returns true if the iteration has more elements.

next
Link copied to clipboard
abstract operator fun next(): T

Returns the next element in the iteration.

Inheritors

UByteIterator
Link copied to clipboard
UShortIterator
Link copied to clipboard
UIntIterator
Link copied to clipboard
ULongIterator
Link copied to clipboard
AbstractIterator
Link copied to clipboard
MutableIterator
Link copied to clipboard
ListIterator
Link copied to clipboard
ByteIterator
Link copied to clipboard
CharIterator
Link copied to clipboard
ShortIterator
Link copied to clipboard
IntIterator
Link copied to clipboard
LongIterator
Link copied to clipboard
FloatIterator
Link copied to clipboard
DoubleIterator
Link copied to clipboard
BooleanIterator
Link copied to clipboard

Extensions

asSequence
Link copied to clipboard
fun <T> Iterator<T>.asSequence(): Sequence<T>

Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once.

forEach
Link copied to clipboard
inline fun <T> Iterator<T>.forEach(operation: (T) -> Unit)

Performs the given operation on each element of this Iterator.

iterator
Link copied to clipboard
inline operator fun <T> Iterator<T>.iterator(): Iterator<T>

Returns the given iterator itself. This allows to use an instance of iterator in a for loop.

withIndex
Link copied to clipboard
fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>>

Returns an Iterator that wraps each element produced by the original iterator into an IndexedValue containing the index of that element and the element itself.